package com.xyz.business.action;

import java.sql.SQLException;

import org.apache.log4j.Logger;

import com.xyz.base.action.BaseAction;
import com.xyz.business.bean.Config;
import com.xyz.business.service.ConfigService;
import com.xyz.init.infos.ConfigInit;

public class ConfigAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5327555429235187359L;
	/**
	 * 
	 */
	private ConfigService configService;
	/**
	 * 日志类
	 */
	private static Logger log = Logger.getLogger(ConfigAction.class);
	public Config config;

	public String view() {
		config = ConfigInit.getConfig("sys_access_ip");
		return SUCCESS;
	}

	/**
	 * 192.168.0.20|192.168.0.88|192.168.0.15|192.168.0.25|192.168.0.22|192.168.0.26|192.168.0.21|192.168.0.27
	 * @return
	 */
	public String update() {
		try {
			configService.updateConfig(config);
		} catch (SQLException e) {
			log.error("更新ip异常");
		}
		ConfigInit.init(configService);
		return SUCCESS;
	}

	public ConfigService getConfigService() {
		return configService;
	}

	public void setConfigService(ConfigService configService) {
		this.configService = configService;
	}

	public Config getConfig() {
		return config;
	}

	public void setConfig(Config config) {
		this.config = config;
	}

}
